<template>
    <div class="container">
        <div class="s1">
            <span class="s1-t1" v-if="member_type == 1">{{ t("升级金卡") }}</span>
            <span class="s1-t2" v-if="member_type == 1">{{ t("尊敬", { name: "青春" }) }}{{ t("升级金卡") }}</span>
            <span class="s1-t1" v-if="member_type == 2">{{ t("您已是金卡会员") }}</span>
            <router-link class="order-btn" to="/">{{ t("去下单") }}</router-link>
        </div>
        <div class="s2">
            <span class="s2-t1">{{ t("会员专属特权") }}</span>
            <div class="s2-icons">
                <span class="icon" v-for="(item, index) in icons" :key="index">
                    <el-image class="icon-img" :src="item.img" fit="fit"></el-image>
                    <span class="icon-t">{{ item.desc }}</span>
                </span>
            </div>
        </div>
        <template v-if="false">
            <div class="s3" v-if="member_type == 1">
                <div class="l1">
                    <span class="l1-t1">{{ t("新会员专属") }}</span>
                    <span class="l1-t1">{{ t("首次下单买一送一") }}</span>
                    <router-link class="order-btn" to="/">{{ t("去下单") }}</router-link>
                </div>
                <div class="l2">
                    <div class="item" v-for="(item, index) in 8" :key="index">
                        <el-image fit="fit"></el-image>
                        <div class="desc">
                            <span class="t1">精选人气印花</span>
                            <span class="price">{{$t("公共.货币符号")}}{{ 500.00 }}</span>
                        </div>
                    </div>
                </div>
            </div>
        </template>
        <div class="s4">
            <div class="s4-1">
                <span class="s4-1-t">{{ t("专属优惠") }}</span>
                <router-link class="order-btn" to="/">{{ t("去下单") }}</router-link>
            </div>
            <div class="s4-2">
                <span class="s4-2-t" v-if="member_type == 1">{{ t("新会员买一送一") }}</span>
                <span class="s4-2-t" v-if="member_type == 2">{{ t("优惠85折") }}</span>
                <span class="s4-2-t" v-if="member_type == 2">{{ t("金卡会员") }}</span>
            </div>
            <div class="s4-3">
                <span class="s4-3-t">{{ t("7折优惠") }}</span>
                <span class="s4-3-t">{{ t("成功推荐会员") }}</span>
            </div>
        </div>
        <!-- </div> -->
    </div>
</template>
<script>
export default {
    data() {
        return {
            /**
             * `vip_level`'会员等级:0=用户,1=银卡会员,2=金卡会员',
             */
            member_type: 1
        }
    },
    computed: {
        icons() {
            return this.member_type == 0 ? [
                {
                    img: require("@/assets/images/mine/member/member-icon-2.png"),
                    desc: this.t("注册优惠")
                },
                {
                    img: require("@/assets/images/mine/member/member-icon-1.png"),
                    desc: this.t("推荐礼物")
                },
                {
                    img: require("@/assets/images/mine/member/member-icon-4.png"),
                    desc: this.t("会员特权")
                },
            ] : [
                {
                    img: require("@/assets/images/mine/member/member-icon-3.png"),
                    desc: this.t("推荐礼物")
                },
                {
                    img: require("@/assets/images/mine/member/member-icon-4.png"),
                    desc: this.t("会员特权")
                },
            ];
        }
    },
    created() {
        this.member_type = this.$store.state.userInfo.vip_level < 2 ? 1 : 2
    },
    methods: {
        /**
         * 简化翻译方法(少写property)
         * @param {String} v 最后一个key值
         * @param {Object} opt 其他参数
         */
        t(v, opt) {
            if (opt) {
                return this.$t(`会员页面.${v}`, opt);
            }
            return this.$t(`会员页面.${v}`);
        },
    },
}
</script>
<style lang="less" scoped>
.container {
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    .s1 {
        margin-top: 27px;
        width: 62%;
        background: linear-gradient(0deg, #BFC3D0 0%, #E3E6EC 100%);
        border-radius: 10px;
        padding: 20px 0px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;

        .s1-t1 {
            margin-bottom: 30px;
            color: #222;
            font-size: 30px;
            font-weight: bold;
        }

        .s1-t2 {
            margin-bottom: 30px;
            color: #222;
            font-size: 22px;
            font-weight: 400;
        }

    }

    .s2 {
        width: 100%;
        margin-top: 50px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;

        .s2-t1 {
            color: #222;
            font-size: 40px;
            font-weight: bold;
        }

        .s2-icons {
            margin-top: 60px;
            width: 100%;
            display: flex;
            justify-content: space-around;
            align-items: center;
            flex-direction: row;

            .icon {
                display: flex;
                justify-content: flex-start;
                align-items: center;
                flex-direction: column;

                .icon-t {
                    color: #222;
                    font-size: 20px;
                    font-weight: 400;
                }

                .icon-img {
                    width: 70px;
                }
            }
        }
    }

    .s3 {
        margin-top: 100px;
        width: 88%;
        background: #F8F8F8;
        border-radius: 8px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        flex-direction: row;

        .l1 {
            flex: 2;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            flex-direction: column;

            .l1-t1 {
                margin-bottom: 30px;
                font-size: 40px;
                color: #222;
                font-weight: bold;
            }
        }

        .l2 {
            padding-top: 20px;
            flex: 5;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            flex-direction: row;
            flex-wrap: wrap;

            .item {
                margin-right: 40px;
                margin-bottom: 20px;
                width: 254px;
                height: 254px;
                border-radius: 6px;
                position: relative;
                background: #fff;
                overflow: hidden;

                .desc {
                    position: absolute;
                    left: 0;
                    bottom: 0;
                    right: 0;
                    background: #222;
                    color: #fff;
                    display: flex;
                    justify-content: flex-start;
                    align-items: flex-start;
                    flex-direction: column;
                    padding: 10px 0px 10px 15px;
                    font-size: 20px;
                }
            }
        }
    }

    .s4 {
        padding: 80px 0px;
        margin-top: 34px;
        width: 88%;
        background: #F8F8F8;
        display: flex;
        justify-content: space-around;
        align-items: center;
        flex-direction: row;

        .s4-1 {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            flex-direction: column;

            .s4-1-t {
                margin-bottom: 34px;
                font-size: 40px;
                color: #222;
                font-weight: bold;
            }
        }

        .s4-2 {
            width: 500px;
            height: 220px;
            background-image: url("../../assets/images/mine/member/member-bg-1.png");
            background-size: cover;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;

            .s4-2-t {
                margin: 20px 0px;
                font-size: 30px;
                color: #fff;
                font-weight: bold;
            }
        }

        .s4-3 {
            width: 500px;
            height: 220px;
            background-image: url("../../assets/images/mine/member/member-bg-2.png");
            background-size: cover;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;

            .s4-3-t {
                margin: 20px 0px;
                color: #fff;
                font-size: 30px;
            }
        }
    }

    .order-btn {
        padding: 0;
        margin: 0;
        background: #222;
        font-size: 24px;
        color: #fff;
        width: 260px;
        text-align: center;
        line-height: 60px;
        border-radius: 8px;
        text-decoration: none;
    }
}
</style>